<template>
	<view class="u-page">
		<card title="基础使用">
			<u-subsection
				:list="list"
				mode="subsection"
				:current="current1"
				@change="change1"
			></u-subsection>
		</card>
		<card title="按钮模式">
			<u-subsection
				:list="list"
				mode="button"
				barColor="#fff"
				:current="current2"
				@change="change2"
			></u-subsection>
		</card>
		<card title="圆角模式">
			<u-subsection
				:list="list"
				mode="subsection"
				shape="circle"
				:current="current2"
				@change="change2"
			></u-subsection>
			<view style="margin-top: 10px;">
				<u-subsection
					:list="list"
					mode="button"
					shape="circle"
					barColor="#3c9cff"
					activeColor="#fff"
					:current="current2"
					@change="change2"
				></u-subsection>
			</view>
		</card>
		<card title="更换主题">
			<u-subsection
				:list="list"
				mode="subsection"
				:current="current3"
				activeColor="#f56c6c"
				@change="change3"
			></u-subsection>

			<view style="margin-top: 10px;">
				<u-subsection
					:list="list"
					mode="button"
					:current="current3"
					activeColor="#fff"
					barColor="#f56c6c"
					@change="change3"
				></u-subsection>
			</view>

			<view style="margin-top: 10px;">
				<u-subsection
					:list="list"
					mode="button"
					height="40"
					shape="circle"
					:current="current3"
					activeColor="#fff"
					barColor="#f56c6c"
					@change="change3"
				></u-subsection>
			</view>
		</card>
		<card title="默认位置">
			<u-subsection
				:list="list"
				mode="button"
				:current="current4"
				@change="change4"
			></u-subsection>
		</card>

		<card title="禁用">
			<u-subsection
				:list="list2"
				mode="button"
				:current="current4"
				@change="change4"
			></u-subsection>
		</card>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current1: 0,
				current2: 0,
				current3: 0,
				current4: 1,
				list: ['未付款', '待评价', '已付款'],
				// 或者如下，也可以配置keyName参数修改对象键值
				list2: [{name: '未付款',disabled: true}, {name: '待评价'}, {name: '已付款'}],
				current: 1
			}
		},
		methods: {
			change1(index,item) {
				this.current1 = index
				console.log('index',index,this.current1,item)
			},
			change2(index) {
				this.current2 = index
				console.log('index',index)
			},
			change3(index) {
				this.current3 = index
				console.log('index',index)
			},
			change4(index) {
				this.current4 = index
				console.log('index',index)
			}
		},
	}
</script>

<style lang="scss">
	.album {
		display: flex;
		flex-direction: row;
		align-items: flex-start;

		&__avatar {
			background-color: $u-bg-color;
			padding: 5px;
			border-radius: 3px;
		}

		&__content {
			margin-left: 10px;
			flex: 1;
		}
	}
</style>
